package com.tensai.study.新概念.响应式编程.reactor.mono;

import org.junit.Test;
import reactor.core.publisher.Mono;

/**
 * @author Tensai
 */
public class FromTest {

    @Test
    public void test() {
        //通过fromRunnable创建，并实现异常处理
        Mono.fromRunnable(() -> {
            System.out.println("thread run");
            throw new RuntimeException("thread run error");
        }).subscribe(System.out::println, System.err::println);

//通过fromCallable创建
        Mono.fromCallable(() -> "callable run ").subscribe(System.out::println);

//通过fromSupplier创建
        Mono.fromSupplier(() -> "create from supplier").subscribe(System.out::println);
    }
}
